<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
%>
<!DOCTYPE html>
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE>left</TITLE>
<META http-equiv=X-UA-Compatible content=IE=EmulateIE7>
<%-- <link rel="stylesheet" href="<%=path%>/css/zTreeStyle/zTreeStyle.css"> --%>
<link rel="stylesheet" href="<%=path%>/css/menu_left_new.css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="<%=request.getContextPath()%>/js/jquery-1.8.3.min.js" type="text/javascript"></script>
<script type="text/javascript" src="<%=path%>/js/ztree/jquery.ztree.core.js"></script>
	<script type="text/javascript">
	var zTreeObj = null;
    $(document).ready(function() {
    	if(window.parent.layoutType == 2){
    		$("#treeDiv").addClass("shortTree");
    	}
    	setLeftTreeDivHeight();
		var setting = {
				data: {
					simpleData: {
						enable: true
					}
				},
				view: {
					// dblClickExpand: true,
					showIcon: true,
					showLine: false
				},
				callback: {
					onClick: openTree
				}
 
			};
		$.ajax({
			url: "<%=path%>/systemManager/menuManage/initMenuList",
			type: "post",
			dataType: "json",
			async:true,
			cache:false,
			success: function(data) {
				// 添加图表配置 iconSkin LFD 20190829 ADDED
				data = $.map(data, function (v, i) {
					if (v.id) {
	                   v.iconSkin = 'icon_' + v.id
					}
					return v
				})
				zTreeObj = $.fn.zTree.init($("#treeDemo"), setting, data);
				// 第一层标题后打开关闭按钮添加 lfd added 20190829 
				$('.ztree li.level0 a.level0').after("<span class='level0_img'></span>")
			},
			error : function() {alert('系统出现异常！请联系管理员！');}
		});
});
    
    function openTree(event, treeId, treeNode){
    	// 添加第一层 class active 20190827 lfd added 
    	if ($('#' + treeNode.tId).attr('class').indexOf('level0')>-1) {
    		// 打开有样式 折叠没样式
    		if (treeNode.open) {
    			$('#' + treeNode.tId).removeClass('active');
    		} else {
                $('#' + treeNode.tId).addClass('active');
    		}
    	} else if ($('#' + treeNode.tId).attr('class').indexOf('level1')>-1) {
    		// 添加第二层 class active 20190828 lfd added
    		// 点击高亮
            $('li.level1').removeClass('active');
            $('#' + treeNode.tId).addClass('active');
    	}

    	if(treeNode.isParent){
    		var isOpen = treeNode.open;
    		zTreeObj.expandNode(treeNode,!isOpen);
    	}
    }
    
    function setLeftTreeDivHeight(){
	    var Sys = {};
	    var ua = navigator.userAgent.toLowerCase();
	    var s;
	    (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :
	    (s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
	    (s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
	    (s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
	    (s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;
	
	    if (Sys.ie){
	    	$('.zTreeDemoBackground').css('height','100%');
//	    	$('treeDiv').removeClass('.zTreeDemoBackground');	
	    }
	    if (Sys.firefox){
	    	$('.zTreeDemoBackground').css('height','100%');
	    }
	    if (Sys.chrome){
	    	$('.zTreeDemoBackground').css('height','100%');
	    }
    } 
	</script>

</HEAD>
<BODY>
<div class="content_wrap" >
	<div class="zTreeDemoBackground left" id="treeDiv">
		<ul id="treeDemo" class="ztree" ></ul>
	</div>
</div>
</BODY>
</HTML>
